var container

function observeAttr(data, attrName, attrVal) {
  addObserve(attrVal);
  Object.defineProperty(data, attrName, {
    configurable: true,
    enumerable: true,
    get: function() {
      if (WatchersContainer.target) {
        container.addWacher(WatchersContainer.target)
      }
      return attrVal
    },
    set: function(newVal) {
      if (newVal === attrVal) {
        return
      }
      // console.log("属性名为" + attrName + "被修改为" + newVal);
      attrVal = newVal
      container.notify()
    }
  })
}

function addObserve(data) {
  if (data === null || typeof data !== "object") {
    return
  }
  Object.keys(data).forEach(key => {
    observeAttr(data, key, data[key])
  })
}